﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


class MaximalIncreaseSequence
{
    static void Main()
    {
        try
        {
            List<int> array = new List<int> { 3, 2, 2, 4, 2, 3, 4, 5, 6};
            List<int> array2 = new List<int>();
            List<int> array3 = new List<int>();
            List<int> copyArray = new List<int>();
            int[] numbers;
            int count = 0;
            int copyvalue = 0;
            int value = 0;
            int number = 0;
            int copynumber = 0;
            int length = array.Count;

            for (int index = 0; index < length; index++)
            {
              
                if ((index != length - 1) && (array[index] + 1 == array[index + 1]))
                {                    
                    while ((index != length - 1) && array[index] + 1 == array[index + 1])
                    {
                        number = array[index];
                        index++;
                        count++;
                        copynumber = index;                       
                    }
                    count += 1;
                    array2.Add(count);
                    array3.Add(number);
                    index = copynumber;
                    count = 0;      
                    if (index == length - 1)
                    {
                        copyArray = array2;
                        copyArray.Sort();
                        foreach (int num in copyArray)
                        {
                            value = num;
                        }

                        foreach (int val in array2)
                        {
                            if (val == value)
                            {
                                copyvalue = val;
                                index = array2.IndexOf(copyvalue);
                                break;
                            }
                        }
                        array3.Sort();
                        copynumber = array3[index] + 1;
                        numbers = new int[copyvalue];
                        for (int j = 0; j < copyvalue; j++)
                        {
                            numbers[j] = copynumber--;                            
                        }
                        numbers = (from vals in numbers orderby vals ascending select vals).ToArray();
                        foreach (int num in numbers)
                        {
                            Console.Write("{0}", num + " ");
                        }
                        Console.WriteLine();
                        return;
                    }
                    
                }
                else if (index == length - 1)
                {
                    copyArray = array2;
                    copyArray.Sort();
                    foreach (int num in copyArray)
                    {
                        value = num;
                    }

                    foreach (int val in array2)
                    {
                        if (val == value)
                        {
                            copyvalue = val;
                            index = array2.IndexOf(copyvalue);
                            break;
                        }
                    }
                    copynumber = array3[index] + 1;
                    numbers = new int[copyvalue];
                    for (int j = 0; j < copyvalue; j++)
                    {
                        numbers[j] = copynumber--;
                    }
                    numbers = (from vals in numbers orderby vals ascending select vals).ToArray();
                    foreach (int num in numbers)
                    {
                        Console.Write("{0}", num + " ");
                    }
                    Console.WriteLine();
                    return;
                }
               
            }

        }
        catch (Exception)
        {
            Console.WriteLine("Wrong data!");
            return;
        }
    }
}